﻿@page
@model ToolGood.FlowVision.Pages.Members.User.EditModel
@{
    Layout = "~/Pages/Shared/_Layout_Edit.cshtml";
}
<div style="overflow-x:hidden">
    <form id="edit-form">
        @Html.AntiForgeryToken()
        <div class="layui-form layui-form-sm" style="padding: 20px 30px 0 0;">
            <div class="layui-form-item-sm">
                <label class="layui-form-label-sm">姓名<span class="red"> *</span></label>
                <div class="layui-input-block-sm">
                    <input type="text" class="layui-input layui-input-sm" id="txt_trueName" name="trueName" value="@Model.Admin.TrueName" autocomplete="off">
                </div>
            </div>

            <div class="layui-form-item-sm">
                <label class="layui-form-label-sm">手机</label>
                <div class="layui-input-block-sm">
                    <input type="text" class="layui-input layui-input-sm" id="txt_phone" name="phone" value="@Model.Admin.Phone" autocomplete="off">
                </div>
            </div>
            <div class="layui-form-item-sm">
                <label class="layui-form-label-sm">邮箱</label>
                <div class="layui-input-block-sm">
                    <input type="text" class="layui-input layui-input-sm" id="txt_email" name="email" value="@Model.Admin.Email" autocomplete="off">
                </div>
            </div>

            <div class="layui-form-item" style="text-align:center;padding-left: 30px;">
                <button type="button" class="layui-btn layui-btn-normal" onclick="save(this);"> &nbsp;&nbsp; 提 交 &nbsp;&nbsp; </button>
                <button type="button" class="layui-btn layui-btn-primary" onclick="closeWindow();"> &nbsp;&nbsp; 关 闭 &nbsp;&nbsp; </button>
            </div>
        </div>

    </form>
</div>
@section js{
    <script>
        function save(obj) {
            if ($("#txt_trueName").val().length ==0) { layer.alert("请输入姓名"); $("#txt_trueName").focus(); return; }

            $(obj).prop("disabled", true);
            var url = "./Ajax/EditMember";
            var data = {
                data: $("#edit-form").serializeJson(),
                fingerprint: window.fingerprint
            }
            $.ajax({
                type: "POST",
                url: url,
                contentType: "application/json;charset=UTF-8",
                data: JSON.stringify(data),
                headers: { __RequestVerificationToken: data.data["__RequestVerificationToken"] },
                dataType: "JSON",
                success: function (data, textStatus, jqXHR) {
                    if (data.state == "SUCCESS") {
                        closeWindowAndReload();
                    } else {
                        $(obj).prop("disabled", false);
                        if (data.message) {
                            layer.msg(data.message);
                        } else {
                            layer.msg("出错了");
                        }
                    }
                },
                error: function (data, textStatus, errorThrown) { $(obj).prop("disabled", false); layer.msg("出错了"); }
            });
        }
    </script>
}
